<?php 
$db = mysql_connect ("localhost","igor","igor");
mysql_select_db ("simple blog");
if(isset($_GET['id'])) {$id = $_GET['id'];}

$result = mysql_query("SELECT id,title,text,date,author FROM main WHERE  id = '$id'");

$myrow = mysql_fetch_array($result);

$text = $myrow ['text'];

$str_text = mb_strlen($myrow ['text'],'UTF-8');




	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $myrow['title'];?></title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<table width="79" border="0" align="center" cellpadding="0" cellspacing="0" class="main_border">
  <tr>
    <td><a href='index.php'><img src="img/header-woman.jpg" width="960" height="200" /></a></td>
  
  </tr>
  <tr>
    <td height="29" align="center" valign="top" bgcolor="#B0C4DE">
   

    <p class='p_s'><a href="edit_article.php?id=<?php echo $id; ?>">Редактировать запись</a></p>



        <p class="p_s"><a href='del_article.php?id=<?php echo $id; ?>' onclick="return confirm('Вы уверенны что хотите удалить запись?')">Удалить запись</a></p>
	      <p>&nbsp;</p>
	      <p class='p_title'><?php echo $myrow['title'];?>
          <p class='p'><?php echo $myrow['text'];?>
		  <p class='p_s'><?php echo $myrow['date'];?>
		  <p class='p_s'><?php echo $myrow['author'];?>
                   
          </p>
          <hr color=#800000 size="2" width="80%"></hr>
          <p align="center"><?php echo "КОММЕНТАРИИ К СТАТЬЕ:";?></p>

 <div align="right">
 <?php 
$result = mysql_query("SELECT text,date,author FROM coments WHERE main_id = '$id' ");

$myrow = mysql_fetch_array($result); 
    
 
	  
  do 
 
 
 {printf (
"<br><div class='p'>%s</div>
<div class='ls'>%s</div>
<div class='ls'>%s</div>
</div><br>", $myrow['text'],$myrow['date'],$myrow['author']);
 
 }
 
 while ($myrow = mysql_fetch_array ($result));
        
				
		?> 
        <hr color=#800000 size="2" width="80%"></hr>
       <form action="add_comment.php" method="post" name="form1" class="ls" id="form1">
            <p>
              <label>Введите автора <br />
            <input type="text" name="author"  id="author" />
            
              </label>
            </p>
            <p>
              <label>Текст комментария<br />
                <textarea name="text" id="text" cols="40" rows="20"></textarea>

              </label>
            </p>
                 <input name="id" type="hidden" value="<?php echo $id; ?>" />
                        
            <p>
              <label>
                <input type="submit" name="submit" id="submit" value="Комментировать" />
              </label>
            </p>
          </form>
          
         
    <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td><img src="img/iuh.jpg" width="960" height="28" /></td>
  </tr>
</table>


</body>
</html>
